package com.ncucoder.soms.interceptor;

import com.ncucoder.soms.util.IpUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 *
 *
 * @author <a href="https://www.ncucoder.com">hsowan</a>
 * @date 2019-07-10
 */
public class UserInterceptor implements HandlerInterceptor {

    private Logger logger = LoggerFactory.getLogger(UserInterceptor.class);

    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {

        // 打印访问ip
        logger.info(IpUtils.getIpAddress(request));

        return true;
    }

}
